using System;
using System.Collections.Generic;
using System.Text;

namespace WozLib.UI.Ink.SketchProperties
{
  public class SketchPropertyCollection
  {
    private Dictionary<WozPropertyType, SketchProperty> _WozProperties = new Dictionary<WozPropertyType, SketchProperty>();

    // returns a copy of all our properties in an array
    public List<SketchProperty> WozProperties
    {
      get { 
        List<SketchProperty> properties = new List<SketchProperty>();
        foreach (SketchProperty wozProperty in _WozProperties.Values)
        {
          properties.Add(wozProperty.Clone() as SketchProperty);
        }
        return properties;
      }
      set
      {
        foreach (SketchProperty wozProperty in value)
        {
          SetProperty(wozProperty);
        }
      }
    }

    public void SetProperty(SketchProperty wozProperty)
    {
      if (_WozProperties.ContainsKey(wozProperty.WozPropertyType))
      {
        _WozProperties[wozProperty.WozPropertyType] = wozProperty;
      }
      else
      {
        _WozProperties.Add(wozProperty.WozPropertyType, wozProperty);
      }
    }

    public SketchProperty GetProperty(WozPropertyType wozPropertyType)
    {
      if (_WozProperties.ContainsKey(wozPropertyType))
      {
        return _WozProperties[wozPropertyType];
      }
      else
      {
        return null;
      }
    }

    public void RemoveProperty(WozPropertyType wozPropertyType)
    {
      if (_WozProperties.ContainsKey(wozPropertyType))
      {
        _WozProperties.Remove(wozPropertyType);
      }
    }

    public bool HasProperty(WozPropertyType wozPropertyType)
    {
      return _WozProperties.ContainsKey(wozPropertyType);
    }
  }
}
